#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string.h>
const int S = 302;
int n, l, ret = 0;
void add(char* m,char* d)
{
	
	for (int i = 0; i < l; i++) d[l - i - 1] = m[i];
	l += 2;
	for (int i=0; i <= l; i++) {
		m[i] += d[i];
		if (m[i] >= n)  m[i] -= n, m[i + 1]++;
	}
	while (!m[l - 1])l--;
}
int pdhws(char* m,int n)
{
	for (int i = 0; i < l; i++)
		if (m[i] != m[l - i - 1])return 1;
	return 0;
}
int main()
{
	char m[S] = { 0 };
	char d[S] = { 0 };
	scanf("%d%s", &n, m);
	l = strlen(m);
	for (int i = 0; i < l; i++) {
		if (m[i] >= '0' && m[i] <= '9')m[i] = m[i] - '0';
		else m[i] = m[i] - 'A' + 10;
	}
	while (pdhws(m,n)) {
		ret++; if (ret > 30) { printf("Impossible!"); return 0; }
		add(m,d);
	}
	printf("STEP=%d", ret);
	return 0;
}